var root = {
  value: 1,
  left: null,
  right: {
    value: 2,
    left: {
      value: 3
    }
  }
}

/**
 * @param {TreeNode} root
 * @return {number[]}
 */
var preorderTraversal = function(root) {
  var res = [];
  function traversal (currNode) {
    if (currNode == null) {
      return;
    }
    res.push(currNode.value);
    traversal(currNode.left);
    traversal(currNode.right);
  }
  traversal(root);
  return res
};

console.log(preorderTraversal(root))